package com.tool.grab.vpn;

public class IPAddress {

    public final String Address;
    public final int port;

    public IPAddress(String address, int port) {
        Address = address;
        this.port = port;
    }

    public IPAddress(String ipAddressString) {
        String[] arrStrings = ipAddressString.split("/");
        String address = arrStrings[0];
        int port = 32;
        if (arrStrings.length > 1) {
            port = Integer.parseInt(arrStrings[1]);
        }

        this.Address = address;
        this.port = port;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || !(o instanceof IPAddress)) {
            return false;
        } else {
            return this.toString().equals(o.toString());
        }
    }

    @Override
    public String toString() {
        return String.format("%s/%d", Address, port);
    }
}
